﻿#ifndef CANVASDESKTOP_H
#define CANVASDESKTOP_H

#include <QGraphicsView>
#include <QWheelEvent>


class CanvasDesktop : public QGraphicsView
{
    Q_OBJECT
public:
    CanvasDesktop(QGraphicsScene *scene, QWidget *parent = NULL);
protected:
    virtual void drawBackground(QPainter * painter, const QRectF & rect);
    void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
    void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
protected:
    void focusInEvent(QFocusEvent *event) Q_DECL_OVERRIDE;
    void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
    void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
    void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;

private:
    QPoint _mouseLBtnDown;
    bool _isLBtnDown = false;
private:
    qreal m_scalingOffset;
    QPointF m_ptCenter;
    double m_ratio;
};

#endif // CANVASDESKTOP_H
